package com.seelyn.dowork.repositories;

import com.seelyn.dowork.entities.Category;
import com.seelyn.dowork.entities.CategoryExample;
import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.JdbcType;

public interface CategoryMapper {
    @SelectProvider(type=CategorySqlProvider.class, method="countByExample")
    long countByExample(CategoryExample example);

    @DeleteProvider(type=CategorySqlProvider.class, method="deleteByExample")
    int deleteByExample(CategoryExample example);

    @Delete({
        "delete from st_category",
        "where category_id = #{categoryId,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long categoryId);

    @Insert({
        "insert into st_category (category_id, created_on, ",
        "del_flag, updated_on, ",
        "content, name, parent_id)",
        "values (#{categoryId,jdbcType=BIGINT}, #{createdOn,jdbcType=TIMESTAMP}, ",
        "#{delFlag,jdbcType=VARCHAR}, #{updatedOn,jdbcType=TIMESTAMP}, ",
        "#{content,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{parentId,jdbcType=BIGINT})"
    })
    int insert(Category record);

    @InsertProvider(type=CategorySqlProvider.class, method="insertSelective")
    int insertSelective(Category record);

    @SelectProvider(type=CategorySqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="category_id", property="categoryId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="created_on", property="createdOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="del_flag", property="delFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="updated_on", property="updatedOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="parent_id", property="parentId", jdbcType=JdbcType.BIGINT)
    })
    List<Category> selectByExampleWithRowbounds(CategoryExample example, RowBounds rowBounds);

    @SelectProvider(type=CategorySqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="category_id", property="categoryId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="created_on", property="createdOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="del_flag", property="delFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="updated_on", property="updatedOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="parent_id", property="parentId", jdbcType=JdbcType.BIGINT)
    })
    List<Category> selectByExample(CategoryExample example);

    @Select({
        "select",
        "category_id, created_on, del_flag, updated_on, content, name, parent_id",
        "from st_category",
        "where category_id = #{categoryId,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="category_id", property="categoryId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="created_on", property="createdOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="del_flag", property="delFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="updated_on", property="updatedOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="parent_id", property="parentId", jdbcType=JdbcType.BIGINT)
    })
    Category selectByPrimaryKey(Long categoryId);

    @UpdateProvider(type=CategorySqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Category record, @Param("example") CategoryExample example);

    @UpdateProvider(type=CategorySqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Category record, @Param("example") CategoryExample example);

    @UpdateProvider(type=CategorySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Category record);

    @Update({
        "update st_category",
        "set created_on = #{createdOn,jdbcType=TIMESTAMP},",
          "del_flag = #{delFlag,jdbcType=VARCHAR},",
          "updated_on = #{updatedOn,jdbcType=TIMESTAMP},",
          "content = #{content,jdbcType=VARCHAR},",
          "name = #{name,jdbcType=VARCHAR},",
          "parent_id = #{parentId,jdbcType=BIGINT}",
        "where category_id = #{categoryId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Category record);
}